#!/bin/bash --
# Copyright (c) 2016, Google Inc. Please see the AUTHORS file for details.
# All rights reserved. Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

if [ $# -ne 0 ]; then
  echo "Usage: tool/use_local_deps"
  echo
  echo "Changes dependencies to use local paths."
fi

for pubspec in */pubspec.yaml; do
  if grep -qv dependency_overrides "$pubspec"; then
    cat >> "$pubspec" <<EOM

dependency_overrides:
EOM

    if [ "$pubspec" != built_value/pubspec.yaml ]; then
      cat >> "$pubspec" <<EOM
  built_value:
    path: ../built_value
EOM
    fi
    if [ "$pubspec" != built_value_generator/pubspec.yaml ]; then
      cat >> "$pubspec" <<EOM
  built_value_generator:
    path: ../built_value_generator
EOM
    fi
  fi
done
